new Vue({
    el:"#audit",
    data:{
        audits:[],
        page:"",

        show:"",
        //场地楼层
        placestorey:"",
        //场地类型
        placetype:"",
        //失约
        dissmiss:[]
    },
    filters: {
        formatDate: function (value) {
            let date = new Date(value);
            let y = date.getFullYear();
            let MM = date.getMonth() + 1;
            MM = MM < 10 ? ('0' + MM) : MM;
            let d = date.getDate();
            d = d < 10 ? ('0' + d) : d;
            return y + '-' + MM + '-' + d ;
        }
    },
    methods:{
        //得到审核数据
        getAudits(pageNum){
            var auditlist;
            var pages;
            $.ajax({
                // 设置json的属性和值
                url: "/getPlaceAudit",
                contentType: "application/json;charset=UTF-8",
                data: {'pageNum':pageNum},
                async:false,
                type: "get",
                success: function (data) {
                    auditlist = data.placeApplies
                    pages = data.pages
                }
            })
            this.audits = auditlist
            this.page = pages
            this.show = '11'
        },
        getMissInfo(){
            var a = []
            $.ajax({
                // 设置json的属性和值
                url: "/getMissInfo",
                contentType: "application/json;charset=UTF-8",
                async:false,
                type: "get",
                success: function (data) {
                    a = data
                }
            })
            this.dissmiss = a
        },
        dealDissMiss(applyid,index){
            $.ajax({
                // 设置json的属性和值
                url: "/dealDissMiss",
                contentType: "application/json;charset=UTF-8",
                data:{'applyid':applyid},
                async:false,
                type: "get",
                success: function (data) {
                    a = data
                }
            })
            this.dissmiss.splice(index,1)
        },
        researchAudits(pageNum){
            var auditlist;
            var pages;
            $.ajax({
                // 设置json的属性和值
                url: "/getPlaceAudit1",
                contentType: "application/json;charset=UTF-8",
                data: {
                    'pageNum':pageNum,
                    'placestorey':this.placestorey,
                    'placetype':this.placetype
                },
                async:false,
                type: "get",
                success: function (data) {
                    auditlist = data.placeApplies
                    pages = data.pages
                }
            })
            this.audits = auditlist
            this.page = pages
            this.show = '22'
        },
        //审核
        auditPlace(index,state){
            $.ajax({
                // 设置json的属性和值
                url: "/aduitPlace",
                contentType: "application/json;charset=UTF-8",
                data: {
                    'apply_id':this.audits[index].apply_id,
                    'state':state
                },
                async:false,
                type: "get",
                success: function (data) {
                   alert("已审核")
                }
            })
            this.audits.splice(index,1);
        },
    },
    created(){
        this.getAudits(1)
        this.getMissInfo()
    }
})